# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=obfs4proxy
pkgver=0.0.13
pkgrel=1
pkgdesc='A pluggable transport proxy written in Go.'
groups=('blackarch' 'blackarch-proxy' 'blackarch-networking')
arch=('x86_64' 'aarch64')
url='https://gitlab.com/yawning/obfs4'
license=('BSD')
makedepends=('git' 'go')
optdepends=('tor')
source=("https://gitlab.com/yawning/obfs4/-/archive/obfs4proxy-$pkgver/obfs4-obfs4proxy-$pkgver.tar.gz")
sha512sums=('5be0eacba6848ba89e7b7b873741e39e7807745f4648af63a81000ce1d2380fb0632d4b04e832071ca8051312360a0b79bb8d86f1e0f02a8bb5344fbfeeaf3fe')

build() {
  cd "obfs4-$pkgname-$pkgver"

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname-bin ./$pkgname
}

package() {
  cd "obfs4-$pkgname-$pkgver"

  install -Dm 755 $pkgname-bin "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 "doc/$pkgname.1" "$pkgdir/usr/share/man/man1/$pkgname.1"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/ChangeLog" ChangeLog \
    doc/obfs4-spec.txt
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

